//
//  ViewController.m
//  ZSLimitTextField-master
//
//  Created by safiri on 2018/7/2.
//  Copyright © 2018年 safiri. All rights reserved.
//

#import "ViewController.h"
#import "UITextField+ZSLimit.h"

@interface ViewController ()<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UITextField *idCardTF;

@property (weak, nonatomic) IBOutlet UITextField *phoneTF;

@property (weak, nonatomic) IBOutlet UITextField *phoneSpaceTF;

@property (weak, nonatomic) IBOutlet UITextField *numberTF;

@property (weak, nonatomic) IBOutlet UITextField *uppercaseTF;

@property (weak, nonatomic) IBOutlet UITextField *numberEnglishAlphabetTF;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.idCardTF.delegate = self;
    self.phoneTF.delegate = self;
    self.phoneSpaceTF.delegate = self;
    self.numberTF.delegate = self;
    self.uppercaseTF.delegate = self;
    self.numberEnglishAlphabetTF.delegate = self;
    
    self.idCardTF.limitType = LimitIdCardType;
    self.phoneTF.limitType = LimitPhoneType;
    self.phoneSpaceTF.limitType = LimitPhoneSpaceType;
    self.numberTF.limitType = LimitNumberType;
    self.numberEnglishAlphabetTF.limitType = LimitNumberEnglishAlphabet;
    
    //custom
    self.uppercaseTF.isUppercaseString = YES;
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    if ([textField isEqual:self.phoneSpaceTF]) {
        return [textField limitForPhoneSpaceTypeWithValueChangeString:string shouldChangeCharactersInRange:range];
    }
   return [textField limitWithValueChangeString:string shouldChangeCharactersInRange:range];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
